home *** CD-ROM | disk | FTP | other *** search
/ Garbo / Garbo.cdr / mac / hypercrd / hc2_x / regnpckg.sit / Picture MDEF ƒ / menu demo.c < prev    next >
C/C++ Source or Header  |  1990-12-10  |  1KB  |  59 lines

  1. /* A VERY simple demo of the Picture MDEF for programmers.
  2.  
  3.    Picture MDEF ⌐ 1990, Nigel Perry
  4.    
  5.    Free for personal use and in stacks & applications which are free.
  6.    May not be used for commercial or profit-making purposes or in
  7.    ShareWare without permission.
  8.    
  9.    Nigel Perry (np@doc.ic.ac.uk), Dec 90.
  10.  */
  11.  
  12. #include <stdio.h>
  13. #include <asm.h>
  14. #include "PicMDEF.h"
  15.  
  16. main()
  17. {    MenuHandle mh;
  18.     PicHandle ph;
  19.     nrctHand nh;
  20.     EventRecord event;
  21.     WindowPtr wp;
  22.     union { long l; Point pt; } hit;
  23.  
  24.     printf("Picture MDEF Programmers Demo\nSelect Quit to finish\n\n");
  25.     
  26.     /* shut up LSC */
  27.     Click_On(0);
  28.     
  29.     /* get resources */
  30.     ph = (PicHandle)GetNamedResource('PICT', "\pDemo");
  31.     nh = (nrctHand)GetNamedResource('nrct', "\pDemo");
  32.     /* get menu */
  33.     mh = NewPicMenu((StringPtr)"\pPicture", ph, nh);
  34.     /* stuff in menu bar */
  35.     InsertMenu(mh, 0);
  36.     DrawMenuBar();
  37.     
  38.     /* loop and print menu/item */
  39.     while(1)
  40.     {    if( GetNextEvent(-1, &event)/* && !StdEvent(&event)*/ )
  41.         {    if( FindWindow(event.where, &wp) == inMenuBar )
  42.             {    hit.l = MenuSelect(event.where);
  43.                 printf("Menu: %d Item: %d\n", hit.pt.v, hit.pt.h);
  44.                 /* tear off? */
  45.                 if(hit.pt.h == -1)
  46.                     printf("Palette Loc (%d,%d)\n",
  47.                         (*(PicMenuHandle)mh)->tearLoc.v,
  48.                         (*(PicMenuHandle)mh)->tearLoc.h);
  49.                 /* Quit item, this is a SIMPLE demo! */
  50.                 if(hit.l == 0x20006) break;
  51.                 HiliteMenu(0);
  52.             }
  53.         }
  54.     }
  55.     
  56.     ReleaseResource(ph);
  57.     ReleaseResource(nh);
  58.     DisposePicMenu(mh);
  59. }